<?php

echo('<div id="menu">');
echo('<br/><b><u>MENU</u></b><br/><br/>');
echo('<a href="http://www.w3schools.com/php/php_ref_mysql.asp">Visit W3Schools</a><br/>');

echoLink('search', 'Property Search');
echoLink('akmuser', 'Profile');
echoLink('property-mine', 'My Properties');
echoLink('messages', getMessages());
echoLink('appointment-list', getAppointments());
echoLink('image_upload', 'Upload Images');
echoLink('advertisement-list', 'My Ads');
echoLink('transactions', 'Transactions');
echoLink('stats', 'User Statistics');
//echoLink('', '');

echo('</div>');



function getMessages()
{
	$sqlquery = "SELECT COUNT(*) AS COUNT FROM COMMUNICATIONS WHERE USRID = " . $_SESSION['USRID'] . " AND COM_VIEWED ='NO';" ;

	include('connect.php');
	$result = mysql_query($sqlquery);
	include('disconnect.php');
	if(!$result)
		die('<br />ERROR535<br />SQL Command Error: ' . mysql_error());

	$count = mysql_result($result,0);
	if($count > 0)
		return $Messages = "<b>(". $count.") new messages!</b>";
	else return "Messages";

}

function getAppointments()
{
	$sqlquery = "SELECT COUNT(*) AS COUNT FROM APPOINTMENTS WHERE USRID_ACCEPT = " . $_SESSION['USRID'] . " AND CONFIRMED = FALSE ;" ;

	include('connect.php');
	$result = mysql_query($sqlquery);
	include('disconnect.php');
	if(!$result)
		die('<br />ERROR535<br />SQL Command Error: ' . mysql_error());

	$count = mysql_result($result,0);
	if($count > 0)
		return $Messages = "<b>(". $count.") new appointments!</b>";
	else return "Appointments";

}

?>
